#ifndef TEXTFINDER_H
#define TEXTFINDER_H

#include <QWidget>
#include <QIcon>
#include <QLabel>
#include <QLineEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QFont>
#include <QCheckBox>
#include <QApplication>

class TextFinder : public QWidget
{
    Q_OBJECT
signals:
    void signalFindNext(QString text, bool wholeWordMode, bool caseSensitive);
    void signalFindPrev(QString text, bool wholeWordMode, bool caseSensitive);
    void signalReplace(QString text, QString replacer, bool wholeWordMode, bool caseSensitive, bool loopCallMode=false);
    void signalReplaceAll(QString text, QString replacer, bool wholeWordMode, bool caseSensitive);
private slots:
    void slot_findNext();
    void slot_findPrev();
    void slot_replace();
    void slot_replaceAll();
private:
    QLabel* findTextLabel; QLineEdit* findTextInput;
    QLabel* replacerLabel; QLineEdit* replacerInput;
    QLabel* wholeWordLabel; QCheckBox* wholeWordCheckBox;
    QLabel* caseSensitiveLabel; QCheckBox* caseSensitiveCheckBox;
    QPushButton* findNextButton;
    QPushButton* findPrevButton;
    QPushButton* replaceButton;
    QPushButton* replaceAllButton;

    QHBoxLayout* findTextLayout;
    QHBoxLayout* replacerLayout;
    QHBoxLayout* modeLayout;
    QHBoxLayout* bottomLayout;
    QVBoxLayout* mainLayout;

    QWidget* findTextWidget;
    QWidget* replacerWidget;
    QWidget* modeWidget;
    QWidget* bottomWidget;
    QFont itemFont;

    void changeItemsFont();
public:
    explicit TextFinder(QWidget *parent = nullptr);
    ~TextFinder();
    void getDefaultFontOpts(const char* fontFamily, const int& fontSize, const QFont::Weight& fontWeight, const bool& useItalic);
};

#endif // TEXTFINDER_H
